/**
 * TestNaiveBayes.java created by zhangzhidong 
 * at 上午9:33:22 2016年3月24日
 */
package wekarelated;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import weka.classifiers.Classifier;
import weka.classifiers.bayes.NaiveBayes;
import weka.core.Instances;

/**
 * @author zhangzhidong
 *
 */
public class TestNaiveBayes {
	public static String datasetDir = "/Users/zhangzhidong/var/";
	public static String datasetName = "weather.numeric.arff";
	/**
	 * 上午9:33:22 2016年3月24日
	 * @param args
	 * @throws  
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		NaiveBayes c = new NaiveBayes();
		Instances insts = new Instances(new FileReader(datasetDir+datasetName));
		insts.setClassIndex(insts.numAttributes()-1);
		c.setUseKernelEstimator(true);
		c.buildClassifier(insts);
		System.out.println(c.distributionForInstance(insts.instance(0))[0]);
	}

}
